<?php
class ConfigsController extends AppController {

	var $name = 'Configs';
	var $uses= array('Member');
	function index() {
		  $this->set('namesOfLevel', $this->Tree->namesOfLevel);
        if (!isset($this->data)){
            $this->data = array(
                'DirectCommission' => $this->Tree->directCommission,
                'IndirectCommission' => $this->Tree->indirectCommission,
                'LeadCommission' => $this->Tree->leadCommission,
                'GlobalCommission' => $this->Tree->globalCommission,
            );
        } else {
                $history = array();
                $history['History']['month'] = "00-0000";
                $history['History']['data'] = json_encode($this->data);
                
                $chkHistory = $this->History->findByMonth("00-0000");
                 
                if (!$chkHistory){
                    $this->History->save($history);
                } else {
                    $chkHistory['History']['data'] = $history['History']['data'];
                    $this->History->save($chkHistory);
                }
        }

	}

}
?>